package com.gl.glcourses.repository.impl;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.springframework.stereotype.Repository;

import com.gl.glcourses.repository.dao.IRecursoRepository;
import com.gl.glcourses.repository.dao.ITipoRecursoRepository;
import com.gl.glcourses.vos.Recurso;
import com.gl.glcourses.vos.TipoRecurso;

@Repository
public class JpaRecursoRepository extends JpaProjectRepository<Recurso> implements IRecursoRepository<Recurso>{
	@PersistenceContext
	protected EntityManager em;

	public Recurso findRecurso(Recurso parametro){
		Recurso objeto=null;
		try {

			Query query = em.createQuery("FROM " + Recurso.class
					+ " as objeto WHERE objeto." + " = :param");
			query.setParameter("param", parametro);
			return objeto = (Recurso) query.getSingleResult();

		} catch (Exception e) {
			return null;
		}
		
	}

}



